package windows;


import coordinators.Cordinator;

import java.awt.Container;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;


public class WindowPastry extends JFrame implements ActionListener,KeyListener
{
	/**
	 *
	 */
	private static final long serialVersionUID = 1L;
	private Container Contenedor;
	private JMenuBar mnbBarMain;

	private JMenu mnuFile;
	private JMenuItem mniExit;

	private JMenu mnuElaboratePie;
	private JMenuItem mniElaboratePie;

	private JMenu mnuManegeRecipe;
	private JMenuItem mninaageRecipe;

	private JButton btnExit;

	private JLabel lblTitle;
	private JLabel lblTitleNit;

	Cordinator coordinador;

	public WindowPastry(	WindowPrincipal top)
	{
		super();

		Contenedor = getContentPane();
		Contenedor.setLayout(null);

		mnbBarMain = new JMenuBar();
		setJMenuBar(mnbBarMain);

		mnuFile= new JMenu("Archivo");
		mniExit = new JMenuItem("Salir");
		mnuFile.add(mniExit);
		mnbBarMain.add(mnuFile);

		mnuElaboratePie = new JMenu("Pastel");
		mniElaboratePie = new JMenuItem("Elaborar");
		mnuElaboratePie.add(mniElaboratePie);

		mnbBarMain.add(mnuElaboratePie);

		mnuManegeRecipe = new JMenu("Receta");
		mninaageRecipe = new JMenuItem("Gestionar Receta");
		mnuManegeRecipe.add(mninaageRecipe);

		mnbBarMain.add(mnuManegeRecipe);

		btnExit = new JButton("Salir");
		btnExit.setBounds(270,140,80,25);
		Contenedor.add(btnExit);

		lblTitle = new JLabel("Pasteleria Ing. soft");
		lblTitle.setFont(new Font("Times New Roman", 3, 25));
		lblTitle.setForeground(new java.awt.Color(0, 0, 153));
		lblTitle.setBounds(200,20,240,30);
		Contenedor.add(lblTitle);

		lblTitleNit = new JLabel("NIT: 899.254.321");
		lblTitleNit.setFont(new Font("Script MT Bold", 3, 18));
		lblTitleNit.setForeground(new java.awt.Color(0, 0, 153));
		lblTitleNit.setBounds(225,50,180,30);
		Contenedor.add(lblTitleNit);

		setTitle("Pastelero");
		setSize(470,250);
		setLocation(200,100);
		setResizable(false);

		mniExit.addActionListener(this);
		mniElaboratePie.addActionListener(this);
		mninaageRecipe.addActionListener(this);

		btnExit.addActionListener(this);
		btnExit.addKeyListener(this);

	
	}

	public void actionPerformed(ActionEvent evento)
	{
		if(evento.getSource()==mniElaboratePie)
		{
			coordinador.ProcessElaboratePie();
		}
		if(evento.getSource()==mninaageRecipe)
		{
			coordinador.ProcessManageRecipe();

		}
		if(evento.getSource()==mniExit)
		{
			coordinador.ProcessCloseWindowPastry();
		}
		if(evento.getSource()==btnExit)
		{
			coordinador.ProcessCloseWindowPastry();
		}
	}
	public void keyTyped(KeyEvent e)
	{

	}
	public void keyReleased(KeyEvent e)
	{
		if(e.getKeyCode()==KeyEvent.VK_ENTER)
		{
			System.exit(0);
		}
	}
	public void keyPressed(KeyEvent e)
	{

	}
	public void setCoordinador(Cordinator c)
	{
		coordinador = c;
	}

}
